package cn.com.guanying.android.ui.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import cn.com.guanying.R;
import cn.com.guanying.android.GuanYingApplication;
import cn.com.guanying.javacore.v11.common.AndroidUtil;
import cn.com.guanying.javacore.v11.models.FilmInfo;

public class MovieItemAdapter extends BaseAdapter{
	private ArrayList<FilmInfo> mMovieList;
	private LayoutInflater mInflater;
	private Context mContext;
	public MovieItemAdapter(Context context){
		mContext = context;
		mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	public int getCount() {
		return mMovieList.size();
	}

	public Object getItem(int position) {
		return mMovieList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}
	public void setmMovieList(ArrayList<FilmInfo> mMovieList) {
		this.mMovieList = mMovieList;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView = (LinearLayout)mInflater.inflate(R.layout.item__movie_list, null);
		}
		ImageView image = (ImageView)convertView.findViewById(R.id.home_list_item);
		int imageId = AndroidUtil.getDrawable("moive_"+(position+1));
		image.setBackgroundResource(imageId);
		return convertView;
	}

}
